/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package test.app;

import java.io.File;
import org.restlet.Application;
import org.restlet.Context;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.Restlet;
import org.restlet.data.MediaType;
import org.restlet.data.Status;
import org.restlet.representation.FileRepresentation;

/**
 *
 * @author alex
 */
public class ReadTempApplication extends Application {

   public ReadTempApplication(Context context)
   {
      super(context);
   }
   
   public Restlet createRoot() {
      return new Restlet(getContext()) {
         public void handle(Request request,Response response) {
            File f = new File("/tmp/"+request.getResourceRef().getRemainingPart());
            response.setEntity(new FileRepresentation(f,MediaType.TEXT_PLAIN));
            response.setStatus(Status.SUCCESS_OK);
         }
      };
   }
}
